<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="<%=request.getContextPath()%>/">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>科室列表 - 医疗预约系统</title>
    <link rel="stylesheet" href="statics/css/hisStyle.css">
    <style>
        .header {
            background-color: #2c3e50;
            color: white;
            padding: 20px 0;
            margin-bottom: 30px;
        }
        .header-content {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
        }
        .breadcrumb {
            background-color: #ecf0f1;
            padding: 10px 0;
            margin-bottom: 20px;
        }
        .breadcrumb-content {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }
        .breadcrumb a {
            color: #3498db;
            text-decoration: none;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }
        .hospital-info {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
        }
        .hospital-info h2 {
            color: #2c3e50;
            margin-bottom: 10px;
        }
        .hospital-details {
            color: #7f8c8d;
        }
        .department-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
        }
        .department-card {
            background: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
        }
        .department-card:hover {
            transform: translateY(-5px);
        }
        .department-card h3 {
            color: #2c3e50;
            margin-bottom: 15px;
        }
        .department-info {
            color: #7f8c8d;
            margin-bottom: 15px;
        }
        .department-actions {
            text-align: right;
        }
        .btn {
            padding: 8px 16px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            text-decoration: none;
            display: inline-block;
        }
        .btn-primary {
            background-color: #3498db;
            color: white;
        }
        .btn-primary:hover {
            background-color: #2980b9;
        }
        .btn-secondary {
            background-color: #95a5a6;
            color: white;
        }
        .btn-secondary:hover {
            background-color: #7f8c8d;
        }
    </style>
</head>
<body>
    <div class="header">
        <div class="header-content">
            <h1>医疗预约系统</h1>
            <c:choose>
                <c:when test="${not empty sessionScope.loginUser}">
                    <span>欢迎，${sessionScope.loginUser.username}</span>
                </c:when>
                <c:otherwise>
                    <a href="auth/login" class="btn btn-primary">登录</a>
                    <a href="auth/register" class="btn btn-secondary" style="margin-left: 10px;">注册</a>
                </c:otherwise>
            </c:choose>
        </div>
    </div>

    <div class="breadcrumb">
        <div class="breadcrumb-content">
            <a href="frontend/index">首页</a> > 
            <span>${hospital.hospitalName} - 科室列表</span>
        </div>
    </div>

    <div class="container">
        <div class="hospital-info">
            <h2>${hospital.hospitalName}</h2>
            <div class="hospital-details">
                <p><strong>地址：</strong>${hospital.address}</p>
                <p><strong>电话：</strong>${hospital.hphone}</p>
            </div>
        </div>

        <h2>科室列表</h2>
        <div class="department-grid">
            <c:forEach items="${departments}" var="department">
                <div class="department-card">
                    <h3>${department.deptName}</h3>
                    <div class="department-info">
                        <c:if test="${not empty department.illness}">
                            <p><strong>诊疗范围：</strong>${department.illness}</p>
                        </c:if>
                        <c:if test="${not empty department.equipment}">
                            <p><strong>设备配置：</strong>${department.equipment}</p>
                        </c:if>
                    </div>
                    <div class="department-actions">
                        <a href="frontend/schedules?deptId=${department.deptId}" class="btn btn-primary">
                            查看排班
                        </a>
                    </div>
                </div>
            </c:forEach>
        </div>

        <c:if test="${empty departments}">
            <div style="text-align: center; padding: 40px; color: #7f8c8d;">
                <p>该医院暂无科室信息</p>
            </div>
        </c:if>
    </div>
</body>
</html>
